package com.sketch.controller;

import com.sketch.commom.PageResult;
import com.sketch.commom.Result;
import com.sketch.entity.dto.AdvertiseConfigDTO;
import com.sketch.entity.dto.DeleteDTO;
import com.sketch.entity.dto.VipPrivilegeDTO;
import com.sketch.service.AdvertiseConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "广告配置管理 API")
@RequestMapping(value = "/api/advertiseConfig")
public class AdvertiseConfigController {
    @Resource
    private AdvertiseConfigService advertiseConfigService;
    /**
     * 新增或更新
     */
    @PostMapping("/addOrUpdate")
    @ApiOperation("新增或更新")
    public Result addOrUpdate(@RequestBody AdvertiseConfigDTO advertiseConfigDTO) {
        return advertiseConfigService.addOrUpdate(advertiseConfigDTO);
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation("列表")
    public Result<PageResult<AdvertiseConfigDTO>> list(@RequestParam(value = "page", defaultValue = "1", required = false) Integer page,
                                                    @RequestParam(value = "size", defaultValue = "20", required = false) Integer size) {
        return advertiseConfigService.list(page, size);
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperation("剧场详情")
    public Result<AdvertiseConfigDTO> detail(@ApiParam(value = "id") @RequestParam Long id){
        return advertiseConfigService.detail(id);
    }

    /**
     * 删除
     */
    @GetMapping("/delete")
    @ApiOperation("删除")
    public Result delete(@RequestBody DeleteDTO deleteDTO) {
        return advertiseConfigService.delete(deleteDTO.getId());
    }

}
